package com.ambulance.project.biz.util;



import com.ambulance.project.biz.util.agora.media.RtcTokenBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


@Component
public class RtcTokenBuilderSample {

    @Value(("${agora.appId}"))
    private String appId;
    @Value(("${agora.appCertificate}"))
    private String appCertificate;
    @Value(("${agora.expirationTimeInSeconds}"))
    private int expirationTimeInSeconds;

    // int uid = 2082341273;
    //生成token
    public String getToken(String channelName, String userAccount) {
        RtcTokenBuilder token = new RtcTokenBuilder();
        int timestamp = (int) (System.currentTimeMillis() / 1000 + expirationTimeInSeconds);
        String result = token.buildTokenWithUserAccount(appId, appCertificate,
                channelName, userAccount, RtcTokenBuilder.Role.Role_Publisher, timestamp);

        return result;

    }
}
